package com.example.alibabanacosdiscoveryclient01.service.impl;

import com.example.alibabanacosdiscoveryclient01.service.MockOrderService;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import org.springframework.stereotype.Service;

import java.util.function.Function;

/**
 * @author:guoq
 * @date:2025/1/16
 * @descripion:
 */
@Service
public class MockOrderServiceImpl  implements MockOrderService, Function<MockOrderServiceImpl.Request, MockOrderServiceImpl.Response> {

    public Response mockOrder(Request request) {
        String productName = "尤尼克斯的羽毛球拍";// 模拟productName
        return new Response(String.format("%s的订单编号为%s, 购买的商品为: %s", request.userCode, request.orderCode, productName));

    }

    @Override
    public Response apply(Request request) {
        return mockOrder(request);
    }


    @JsonInclude
    public record  Request(
     @JsonProperty(required = true,value = "orderCode")@JsonPropertyDescription("订单编号,比如0001")String orderCode,
     @JsonProperty(required = true,value = "userCode")@JsonPropertyDescription("用户编号,比如zs")String userCode){
    }
    public  record Response(String description){

    }

}
